let bigArray = [
    { id: 1110, name: '张三-', pid: 1000 },
    { id: 0, name: '张三-', pid: 1000 },
    { id: 10, name: '张三-1', pid: 0 },
    { id: 11, name: '张三-2', pid: 0 },
    { id: 12, name: '张三-3', pid: 0 },
    { id: 13, name: '张三-4', pid: 0 },
    { id: 20, name: '张三-5', pid: 13 },
    { id: 21, name: '张三-6', pid: 13 },
    { id: 14, name: '张三-12', pid: 0 },
    { id: 23, name: '张三-13', pid: 14 },
    { id: 25, name: '张三-14', pid: 14 }
  ]
function toTree(arr){
    let map = new Map();
    let roots=[]
    arr.forEach(element => {
        map.set(element.id,element)//value 是内存地址
    });
    arr.forEach(item=>{
        let parent = map.get(item.pid)//获取该项的内存地址
        if(parent){
            (parent.children || (parent.children=[])).push(item)
        }else{
            roots.push(item)
        }
    })
    
    return roots
}
let tree = toTree(bigArray)
console.log(tree)